<html>
	
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> 
<title>CS4380 Yahoo! YUI Testing</title>  
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.4.1/build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
</head> 
 
<body> 

<h1>Blogger Autocomplete</h1> 
 
<div id="demo" class="yui3-skin-sam">
  <label for="author">Author</label><br>
  <input id="author" type="text">
</div>
 
<script type="text/javascript">

	var blogusers = new Array();
	
	$.ajax({
		url:"../scripts/proxyBlog.cgi",
		type:"get",
		data:"method=getBlogs&type=json",
		dataType:"json",
		success:function(data) {
			for(var i in data.Blogs) {
				var blog_user = data.Blogs[i];
				blogusers.push(blog_user);
			}			
		},
		error:function(xhr, ajaxOptions, thrownError) {
			alert(xhr.status);
            alert(thrownError);
		}
	});


	YUI().use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', function (Y) {
		
		Y.one('#author').plug(Y.Plugin.AutoComplete, {
			resultFilters: 'Blogs',
			//resultHighlighter: 'phraseMatch',
			source: blogusers
		});

</script>

</body>
</html>
